refactor(core): drop redundant viewport-mercator-project dependency - #2881
Conversation
`packages/core/package.json` declared both `viewport-mercator-project` and
`@types/viewport-mercator-project` as direct deps, but `packages/core/src`
never actually imports the package. The only mention is a documentation
URL comment in `CoordinateSystemService.ts:124` which is not a code usage.
The real runtime consumer is `packages/maps/src/lib/web-mercator-viewport.ts`
(value `import WebMercatorViewport from 'viewport-mercator-project'`,
exercised by all 8 map adapters). `packages/maps/src/earth/Viewport.ts`
uses a `import type` for an interface-only field, also covered by the
maps-scope declaration. The maps package therefore retains its own
declaration and the workspace dependency graph is unchanged — pnpm-lock
only drops the importer-of-record lines for core (-6 lines).
背景/Investigation note
-----------------------
A prior turn looked into modernizing `viewport-mercator-project` to the
latest npm tag. That tag (7.0.4) is **deprecated** by vis.gl and is
literally `module.exports = require('@math.gl/web-mercator')` — the
underlying `@math.gl/web-mercator@4.1.0` uses a different projection
convention (no `2^zoom` scaling on `projectFlat`/`center`, different
matrix conventions). Runtime comparison at the same options showed a
`2^zoom` factor divergence between v6.2.3 and v4.1.0, which would break
L7's rendering pipeline downstream (layers/shaders/CameraService).
So a full migration to the latest is **out of scope** for this PR. v6.2.3
itself is *not* deprecated (only the npm-latest wrapper is). The only
uncontroversially-safe cleanup is removing core's dead direct
declaration, which is what this commit does. A future "vendor v6 source
into the repo" PR (preserve v6 behavior exactly, remove external dep)
is feasible but requires its own risk review.
|
There was a problem hiding this comment.
Code Review
This pull request removes the unused dependency viewport-mercator-project and its corresponding TypeScript types @types/viewport-mercator-project from the packages/core package, updating the lockfile accordingly. There are no review comments, and I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
What
packages/core/package.jsondeclared bothviewport-mercator-projectand@types/viewport-mercator-projectas direct deps, butpackages/core/srcnever actually imports the package — the only mention is a documentation URL comment inCoordinateSystemService.ts:124, which is not a code usage.This PR removes the redundant declarations from core.
The real runtime consumer is
packages/maps/src/lib/web-mercator-viewport.ts(valueimport WebMercatorViewport from 'viewport-mercator-project', exercised by all 8 map adapters).packages/maps/src/earth/Viewport.tsuses animport typefor an interface-only field that is never instantiated and whoseprojectFlatis never called fromearth/map.ts— also covered by the maps-scope declaration, not core's.The maps package therefore retains its own declaration and the workspace dependency graph is essentially unchanged —
pnpm-lock.yamlonly drops the importer-of-record lines for core (-6 lines).Why now (modernization investigation)
A prior turn looked into modernizing
viewport-mercator-projectto the latest npm tag. Findings:7.0.4) is deprecated by vis.gl and is literallymodule.exports = require('@math.gl/web-mercator')under the hood.@math.gl/web-mercator@4.1.0uses a different projection convention — no2^zoomscaling onprojectFlat/center, and substantially different matrix conventions.{width,height,longitude,latitude,zoom,pitch,bearing}options showed a2^zoomfactor divergence inprojectFlat/center, which would break L7's rendering pipeline downstream (layers / shaders /CameraService).A full migration to the latest is therefore out of scope for this PR. The only uncontroversially-safe cleanup is removing core's dead direct declaration — which is what this commit does.
A future "vendor v6 source into the repo" PR (preserve v6 behavior exactly, remove the external dep completely) is feasible but requires its own risk review and visual regression pass, and is not in scope here.
Changes
packages/core/package.json— removedviewport-mercator-project(^6.2.1) fromdependencies,@types/viewport-mercator-project(^6.1.0) fromdevDependencies.pnpm-lock.yaml— drops 6 lines (the importer-of-record entry for core; the package itself stays because maps still uses it transitively).packages/maps/package.jsonis intentionally untouched — maps is the legitimate consumer.Validation
tsc --noEmit -p packages/core/tsconfig.json: clean.tsc --noEmit -p packages/maps/tsconfig.json: only pre-existing baseline noise (.glslmodule resolution + unrelatedcamera.tsundefined checks); no new errors from this change.prettier(CI'scheck-format.shglob**/*.{ts,tsx,js,jsx,json,md,css,less}):packages/core/package.jsonclean. (Lockfile yaml is outside CI's prettier glob.)Risk
Zero runtime risk — core has no actual code usage of the package. Maps and the rest of the rendering pipeline are untouched.